﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Visa_infoFormAdd.aspx.cs" Inherits="FS.Web.BLL.Visa_Base.Visa_infoFormAdd" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>    
    <meta http-equiv="X-UA-Compatible" content="IE=8" /><!--以IE8模式渲染--> 
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Fadd() {
            var trust = $("#trust_id").val();
            var countryid = $("#detail_city").val();
            var certtypeid = $("#detail_type").val();
            var customer = $("#detail_customer").val();
            var cardno = $("#detail_cardno").val();
            var cprice = $("#detail_begmoney").val();
            var infoid = $("#Hinfo").val();
            var supplyid = $("#detail_supply").val();
            var sprice = $("#HD_Sprice").val();
            var viewprice = $("#HD_viewprice").val();

            if (trust == "") {
                showTipsMsg("请选择委托方！", 2000, 5);
                return false;
            }
            if (countryid == "") {
                showTipsMsg("请选择签证国家！", 2000, 5);
                return false;
            }
            if (certtypeid == "") {
                showTipsMsg("请选择签证类型！", 2000, 5);
                return false;
            }
            if (cprice == "" || cprice == 0) {
                cprice = "0";
            }
            if (customer == "") {
                showTipsMsg("请输入客户名称！", 2000, 5);
                return false;
            }

            var parm = "";
            if (viewprice == "1") {
                if (supplyid == "") {
                    showTipsMsg("请选择供应商！", 2000, 5);
                    return false;
                }
                parm = 'action=InsertInfoDetailWithSupply&cityid=' + escape(countryid) + '&certtype=' + escape(certtypeid) +
                   '&cprice=' + escape(cprice) + '&infoid=' + escape(infoid) +
                   '&insert_user=' + escape(customer) + '&insert_cardno=' + escape(cardno) +
                   '&supplyid=' + escape(supplyid) + '&sprice=' + escape(sprice);
            }
            else {
                parm = 'action=InsertInfoDetail&cityid=' + escape(countryid) + '&certtype=' + escape(certtypeid) +
                   '&cprice=' + escape(cprice) + '&infoid=' + escape(infoid) +
                   '&insert_user=' + escape(customer) + '&insert_cardno=' + escape(cardno);
            }

            getAjax('info.ashx', parm, function (rs) {
                try {
                    if (rs != "ok") {
                        showTipsMsg("<span style='color:red'>" + rs + "</span>", 4000, 5);
                        return false;
                    }
                } catch (e) {
                }
            });
        }
        function ChangeArea() {
            var cityarea = $("#detail_area").val();
            var parm = 'action=getcitybyarea&cityarea=' + escape(cityarea);
            getAjax('base.ashx', parm, function (rs) {
                try {
                    var json = eval("(" + rs + ")");
                    $("#detail_city").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到区域下的国家信息，请到【国家信息】窗口维护！", 2000, 5);
                    } else {
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_city").append("<option value='" + menu.CITY_ID +
                                "'>" + menu.CITY_NAME + "</option>");
                        }
                    }
                } catch (e) {
                }
            });
        }
        function ChangeCity() {
            var cityid = $("#detail_city").val();

            var parm = 'action=getcerttype&cityid=' + escape(cityid);
            getAjax('base.ashx', parm, function (rs) {
                try {
                    var json = eval("(" + rs + ")");
                    $("#detail_type").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到签证国家下的签证类型，请到【签证国家】窗口维护！", 2000, 5);
                    } else {
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_type").append("<option value='" + menu.ID +
                                "'>" + menu.NAME + "</option>");
                        }
                        ChangeType();
                    }
                } catch (e) {
                }
            });
        }

        function ChangeType() {
            var certtype = $("#detail_type").val();
            var cityid = $("#detail_city").val();
            var trusttype = $("#Hpricecode").val();  //委托方价格类型            

            if (trusttype == "") {
                showTipsMsg("请选择委托方或定义委托方类型！", 2000, 5);
                return false;
            }

            var parm = 'action=GetPriceFromCityCert&cityid=' + escape(cityid) + '&certtype=' + escape(certtype) + '&trusttype=' + escape(trusttype);
            getAjax('base.ashx', parm, function (rs) {
                try {
                    $("#detail_begmoney").val(rs);
                } catch (e) {
                }
            });

            var view = $("#HD_viewprice").val();
            if (view == "1") {
                GetSupplyList();
            }
        }

        function GetSupplyList() {
            var certtype = $("#detail_type").val();
            var cityid = $("#detail_city").val();

            var parm = 'action=GetSupplybycitycert&cityid=' + escape(cityid) + '&certtype=' + escape(certtype)
            getAjax('base.ashx', parm, function (rs) {
                try {
                    var json = eval("(" + rs + ")");
                    $("#detail_supply").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到签证国家下的签证类型，请到【签证国家】窗口维护！", 2000, 5);
                    } else {
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_supply").append("<option value='" + menu.SUPPLY_ID +
                                "'>" + menu.SUPPLYPRICE + "</option>");
                        }
                        ChangeSupply();
                    }
                } catch (e) {
                }
            });
        }

        function ChangeSupply() {
            var ls_txt = $("#detail_supply").find("option:selected").text();
            var ls_price = ls_txt.split(":");
            $("#HD_Sprice").val(ls_price[1]);
        }

        function GetTrustInfo() {
            var trust = $("#trust_id").val();
            if (trust != "") {
                var parm = 'action=gettrustinfo&trust_id=' + escape(trust);
                getAjax('base.ashx', parm, function (rs) {
                    try {
                        if (rs != "") {
                            var tmp = rs.split("@");
                            $("#Ref_trusttype").val(tmp[0]);
                            //$("#Ref_pricetype").val(tmp[1]);
                            $("#info_contactnumber").val(tmp[2]);
                            $("#info_contactuser").val(tmp[3]);
                            $("#Hpricecode").val(tmp[4]);
                            $("#info_operation").val(tmp[5]);
                        } else {
                            showTipsMsg("找不到委托方信息，！", 2000, 5);
                        }
                    } catch (e) {
                    }
                });
            }
        }
        //删除
        function FDel() {
            var key = CheckboxValue();
            if (IsEditdata(key)) {
                $("#HDetailID").val(key);
            }
        }

        //添加客户
        function AddTrust() {
            var url = "/BLL/Visa_Base/Base_TrustForm.aspx";
            top.openDialog(url, 'Menu_Form', '委托人列表信息 - 添加', 550, 230, 50, 50);
        }

        //添加供应商
        function AddSupply() {
            var url = "/BLL/Visa_Base/Base_SupplyForm.aspx";
            top.openDialog(url, 'Menu_Form', '供应商列表信息 - 添加', 550, 230, 50, 50);
        }

        //修改收款方式
        function ChangeMoneyFlag() {
            var moneyflag = $("#Ref_moneyflag").val();
            var moneytype = "month";
            if (moneyflag == "yes") {
                moneytype = "money";
            }

            $("#Ref_moneytype").get(0).value = moneytype;
        }
    </script>       
</head>
<body>    
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <input id="Hinfo" type="hidden" runat="server"  />
    <input id="Hpricecode" type="hidden" runat="server"/>         
    <input id="HDetailID" type="hidden" runat="server"/> 
    <input id="HD_viewprice" type="hidden" runat="server" value="0"/> 
    <input id="HD_Sprice" type="hidden" runat="server" value="0"/> 
    <input id="HD_AddNo" type="hidden" runat="server" value="0"/>              
    <table border="0" cellpadding="0" cellspacing="0" class="frm">                
        <tr>
            <th>
                单号：
            </th>
            <td>
                <input id="info_no" runat="server" type="text" disabled="disabled" class="select" datacol="yes" style="width: 140px" />
            </td>                              
            <th>
                 签证状态：</th>                   
            <td>
                <select id="Ref_infoflag" runat="server" disabled="disabled" type="text" class="select" style="width: 146px" />
            </td>
             <th>
                收签时间：
            </th>
            <td>
               <input id="info_getdate" runat="server" type="text" class="txt" datacol="yes" err="收签时间"
                     style="width: 140px" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd' })" />
            </td>                   
        </tr>        
        <tr>
            <th>
                <div>
                委托方：                 
                    <img alt="" src="/Themes/images/16/add.png" onclick="AddTrust()" border="0" style="vertical-align:middle;"
                        id="img_trust" runat="server" />
                 </div>
            </th>
            <td>
                <select id="trust_id" runat="server" type="text" class="select" datacol="yes" err="委托方" 
                    checkexpession="NotNull" style="width: 146px" onchange="GetTrustInfo()" />
                
            </td>
             <th>
                委托方类型：
            </th>
            <td>
                <input id="Ref_trusttype" runat="server" type="text" class="txt" disabled="disabled" style="width: 140px"  />               
            </td>
             <th>
                 业务员：
            </th>
            <td>
               <input id="info_operation" runat="server" type="text" class="txt"  style="width: 140px" />
            </td>
            
        </tr>
        <tr>
            <th>
                联系人：
            </th>
            <td>
                <input id="info_contactuser" runat="server" type="text" class="txt" style="width: 140px" />
            </td>
            <th>
                联系方式：
            </th>
            <td>
               <input id="info_contactnumber" runat="server" type="text" class="txt" style="width: 140px" />
            </td>
            <th>
                团号：
            </th>
            <td>
               <input id="info_TuanNo" runat="server" type="text" class="txt" style="width: 140px" />
            </td>
        </tr>
        <tr>
            <td colspan="6">
            <div class="btnbarcontetn">                   
                <div> 添加客户信息 </div>
            </div>      
            <div id="detail_input" style="width:95%" >
                <table border="0" cellpadding="0" cellspacing="0" id="table_detail" style="width:100%" >                
                <tr>
                    <th >
                        签证国家：</th>
                    <td >
                        <select id="detail_city" runat="server" type="text" class="select" 
                            style="width: 136px" onchange="ChangeCity()" />                                              
                    </td>
                    <th >
                        签证类型：
                    </th>
                    <td >
                        <select id="detail_type" runat="server" type="text" class="select" 
                            style="width: 136px" onchange="ChangeType()" />
                    </td>
                     <th>
                        <div id="price1" runat="server">供应商：
                           <img alt="" src="/Themes/images/16/add.png" onclick="AddSupply()" border="0" 
                               style="vertical-align:middle;" id="img_supply" runat="server" />
                        </div> 
                     </th>
                    <td > 
                        <div id="price2" runat="server">                       
                        <select id="detail_supply" runat="server" type="text" class="select" 
                            style="width: 136px" onchange="ChangeSupply()" /> 
                        </div>                       
                    </td> 
                    <th >
                        <asp:LinkButton ID="lbtadd" runat="server" class="button green" OnClick="lbtadd_Click" OnClientClick="return Fadd()" >
                            <span class="icon-botton"  style="background: url('/Themes/images/16/add.png') no-repeat scroll 0px 4px;">
                            </span>添 加
                        </asp:LinkButton>                        
                    </th>                    
                </tr>
                <tr>                                                          
                    <th>
                        客户姓名：
                    </th>                    
                    <td>
                        <input id="detail_customer" runat="server" type="text" class="txt" style="width: 130px" />                        
                    </td>  
                     <th>
                         护照号：
                    </th>
                    <td>
                        <input id="detail_cardno" runat="server" type="text" class="txt" style="width: 130px" />                        
                    </td>
                    <th>                        
                        签证费用：</th>
                    <td>
                        <input id="detail_begmoney" runat="server" type="text" readonly="readonly" class="txt" 
                            style="width: 130px" /></td>
                    <th>
                        <asp:LinkButton ID="lbtdel" runat="server" class="button green" OnClientClick="FDel()" OnClick="lbtdel_Click" ><span class="icon-botton"  style="background: url('/Themes/images/16/delete.png') no-repeat scroll 0px 4px;">
                            </span>删 除</asp:LinkButton>
                    </th>                    
                </tr>
                </table>                                              
            </div>
           <div id ="detailsub1" style="height:130px; width:98%; overflow:auto; ">
               <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
               <ContentTemplate >
                <table id="table1" class="grid" singleselect="true">
                    <thead>
                        <tr>
                            <td style="width: 20px; text-align: left;">
                                <label id="checkAllOff" onclick="CheckAllLine()" title="全选">
                                    &nbsp;</label>
                            </td>
                            <td style="width: 30px; text-align: center;">
                                序号
                            </td> 
                            <td style="width: 100px; text-align: center;">
                                签证国家
                            </td> 
                            <td style="width: 80px; text-align: center;">
                                签证类型
                            </td>
                            <td style="width: 80px; text-align: center;">
                                费用
                            </td>
                            <td style="width: 100px; text-align: center;">
                                客户姓名
                            </td> 
                            <td style="width: 100px; text-align: center;">
                                护照号
                            </td>
                        </tr>
                    </thead>
                    <tbody> 
                        <asp:Repeater ID="rp_Item" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td style="width: 20px; text-align: left;">
                                    <input type="checkbox" value="<%#Eval("infodetail_id")%>" name="checkbox" />
                                </td>
                                <td style="width: 30px; text-align: center;">
                                    <%#Eval("id")%>
                                </td>                            
                                <td style="width: 100px;">
                                    <%#Eval("city_name")%>
                                </td> 
                                    <td style="width: 80px;">
                                    <%#Eval("property_value")%>
                                </td>
                                <td style="width: 80px;">
                                    <%#Eval("InfoDetai_BegPrice")%>       
                                </td>
                                <td style="width: 100px;">
                                    <%#Eval("InfoDetail_user")%>
                                </td> 
                                <td style="width: 100px;">
                                    <%#Eval("InfoDetail_cardno")%>
                                </td>                         
                            </tr>                                
                        </ItemTemplate>
                        <FooterTemplate>
                            <% if (rp_Item != null)
                                {
                                    if (rp_Item.Items.Count == 0)
                                    {
                                        Response.Write("<tr><td colspan='7' style='color:red;text-align:center'>没有找到您要的相关数据！</td></tr>");
                                    }
                                } %>
                        </FooterTemplate>
                    </asp:Repeater>                               
                    </tbody>
                </table>
                </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="lbtadd" EventName="Click" />
                        <asp:AsyncPostBackTrigger ControlID="lbtdel" EventName="Click" />
                    </Triggers>
            </asp:UpdatePanel> 
            </div> 
            </td>
        </tr>
        <tr>
            <td colspan="6">

            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <th>
                        人数：
                    </th>
                    <td>               
                        <input id="info_outpeople" runat="server" type="text" disabled="disabled" class="txt" datacol="yes" err="人数"
                            checkexpession="Num" style="width: 140px" value="0" />
                    </td>
                     <th>
                        签证费用：
                    </th>
                    <td>
                       <input id="info_outmoney" runat="server" type="text" disabled="disabled" class="txt" datacol="yes" err="取件费用"
                            checkexpession="DoubleOrNull" style="width: 140px" value="0" />
                    </td>
                     <th>
                        收款情况：
                    </th>
                    <td>
                       <select id="Ref_moneyflag" runat="server" type="text" class="select"  style="width: 146px" onchange="ChangeMoneyFlag()">   
                       </select>            
                    </td>
                    
                </tr>
                <tr>
                    <th>
                        取件类型：
                    </th>
                    <td>               
                        <select id="Ref_postby" runat="server" type="text" class="select"  style="width: 146px"></select>                 
                     </td>
                     <th>
                        取件费用：
                    </th>
                    <td>
                       <input id="Ref_postmoney" runat="server" type="text" class="txt" datacol="yes" err="取件费用"
                            checkexpession="DoubleOrNull" style="width: 140px" value="0" />
                    </td>
                    <th>
                        收款方式：
                    </th>
                    <td>
                        <select id="Ref_moneytype" runat="server" type="text" class="select"  style="width: 146px" ></select>                
                     </td>
                </tr>
                <tr>
                    <th>
                        发票信息：
                    </th>
                    <td>
                       <input id="Info_fapiao" runat="server" type="text" class="txt" datacol="yes" style="width: 140px" />
                    </td>
                    <th>
                        发票金额：
                    </th>
                    <td>
                        <input id="info_moneyfapiao" runat="server" type="text" class="txt" datacol="yes" err="发票金额"
                            checkexpession="DoubleOrNull" style="width: 140px" value="0" />               
                    </td>
                    <th>
                        &nbsp;</th>
                    <td>
                       &nbsp;</td>
                </tr>
                <tr>
                    <th>
                        应收费用：
                    </th>
                    <td>
                        <input id="info_moneyin" runat="server" type="text" class="txt" datacol="yes" err="应收金额"
                            checkexpession="DoubleOrNull" style="width: 140px" />
                    </td>
                     <th>
                        <div id="price3" runat="server">应付金额：</div> 
                    </th>
                    <td>
                        <div id="price4" runat="server">
                       <input id="info_moneyout" runat="server" type="text" class="txt" datacol="yes" err="应付金额"
                            checkexpession="DoubleOrNull" style="width: 140px" />
                        </div> 
                    </td>
                    <th>
                        &nbsp;</th>
                    <td>
                        &nbsp;</td>    
                </tr>
                </table>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="lbtadd" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbtdel" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <th>
                备注：
            </th>
           <td colspan=5>
                <textarea id="info_remark" class="txtRemark" runat="server" style="width: 95%;
                    height: 50px;"></textarea>
            </td>           
        </tr>
    </table>
    <div class="frmbottom">
        <asp:LinkButton ID="SaveAdd" runat="server" class="l-btn" OnClientClick="return CheckDataValid('#form1');"
            OnClick="SaveAdd_Click"><span class="l-btn-left">
            <img src="/Themes/Images/save.png" alt="" />新 增</span></asp:LinkButton>
        <asp:LinkButton ID="Save" runat="server" class="l-btn" OnClientClick="return CheckDataValid('#form1');"
            OnClick="Save_Click"><span class="l-btn-left">
            <img src="/Themes/Images/save.png" alt="" />保 存</span></asp:LinkButton>              
    </div>
    </form>
</body>
</html>
